package android.xml;

import java.io.InputStream;
import java.util.List;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

public class ItemsParser {

	public static List<?> parse(InputStream is, ItemsHandler<?> handler)
			throws Exception {

		//se zema SAXParser od SAXPArserFactory
		SAXParserFactory spf = SAXParserFactory.newInstance();
		SAXParser sp = spf.newSAXParser();

		//se zema xml citac otkako ke se kreira parserot
		XMLReader xr = sp.getXMLReader();
		xr.setContentHandler(handler);

		//se vrsi parsiranjeto za vlezniot podatok
		xr.parse(new InputSource(is));
		
		//otkako parsiranjeto ke zavrsi se vraka dobieniot podatok
		return handler.getItems();

	}
}
